/**
 *
 */
package com.wedroid.r2d2.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.wedroid.r2d2.app.DroidManager;
import com.wedroid.r2d2.app.DroidStatus;

/**
 * @author lute
 *
 */
@Controller
public class MainController {

    @Autowired
    private DroidManager droidManager;

    /**
     * @return
     */
    @RequestMapping("/")
    public ModelAndView main() {
        ModelAndView modelAndView = new ModelAndView("index");
        DroidStatus status = droidManager.start();
        if (status.equals(DroidStatus.WAIT_LOGIN)) {
            String qrcode = droidManager.getQR();
            modelAndView.addObject("qrcode", qrcode);
        }
        modelAndView.addObject("status", status.name());
        return modelAndView;
    }

}
